home *** CD-ROM | disk | FTP | other *** search
- // ** Lan Server **
-
- // * functions
-
- func void fnLanBroadcast_CreateReceiver()
- {
- /*if (!g_pLanUDPServer)
- {
- g_pLanUDPServer = NetUDPServer_Constructor(G_iLanBroadcastPort, fnLanBroadcastCB);
- }*/
- }
-
- func void fnLanBroadcast_DestroyReceiver()
- {
- /*if (g_pLanUDPServer)
- {
- NetUDPServer_Destructor(g_pLanUDPServer);
- g_pLanUDPServer = g_pNullUDPServer;
- }*/
- }
-
- // * callbacks
-
- // reception from an udp broadcast : connect to the same ip and to the given port
- func void fnLanBroadcastCB(szx szIP, i32x iPort, szx szString)
- {
- var Net_Client pClient;
- iPort = atoi(szString);
- if (iPort>0)
- {
- /*pClient = NetClient_CreateObsolete(
- szIP,
- iPort,
- NullInterface,
- LanBroadcastConnectCB,
- LanBroadcastDisconnectCB);*/
- }
- }
-
- func void LanBroadcastConnectCB(Net_Client pClient)
- {
- // tutu debug : should look in local Menu Server
- var i32x iNumConnected;
- iNumConnected = 0;
-
- // give game parameters
- pClient << mLanGame(Join_GetStringFromIndex( g_oLocalJoins.m_iUser_szName, 0),g_iServerPort,g_oGameConfig.m_iGameMode,iNumConnected);
- }
-
- func void LanBroadcastDisconnectCB(Net_Client pClient)
- {
- }
-
-
- // ** Lan Client **
-
-
- func void fnLanBroadcast()
- {
- var Net_UDPClient pClient;
- var i32x iGamesTable;
-
- // broadcast lobby port
- pClient = NetUDPClient_Constructor("*",G_iLanBroadcastPort);
- //NetUDPClient_SendString(pClient,itoa(g_iServerPort));
- NetUDPClient_Destructor(pClient);
-
- // reset games
- iGamesTable = Table_GetIndexFromName(QUERY_GAME_SERVERS,"Games");
- Table_DeleteAllRows(QUERY_GAME_SERVERS, iGamesTable);
- Database_DeleteNow(QUERY_GAME_SERVERS);
- }
-
-
- func void fnGateway_LanGame(szx szName,i32x iPort,i32x iGameMode,i32x _iNumConnected)
- {
- print("lan game name:");println(szName);
- print("lan game port:");println(itoa(iPort));
- print("lan game mode:");println(itoa(iGameMode));
- print("lan game connected:");println(itoa(_iNumConnected));
-
- var Net_Client pClient;
- var szx szIp;
- var i32x iTableGame, iNewRow;
-
- pClient = GetCurrentClient();
- szIp = NetClient_GetDistantIP(pClient);
- print("lan game ip:");println(szIp);
-
- iTableGame = Table_GetIndexFromName(QUERY_GAME_SERVERS,"Games");
- iNewRow = Table_AddRow(QUERY_GAME_SERVERS,iTableGame);
-
- Join_SetStringFromIndex( g_oGatewayJoins.m_iGame_szDescJoin, iNewRow, szName);
- Join_SetIntFromIndex( g_oGatewayJoins.iGameMode, iNewRow, iGameMode);
- Join_SetIntFromIndex( g_oGatewayJoins.bHasPassword, iNewRow, 0);
- Join_SetStringFromIndex( g_oGatewayJoins.szIP, iNewRow, szIp);
- Join_SetIntFromIndex( g_oGatewayJoins.iPort, iNewRow, iPort);
- Join_SetIntFromIndex( g_oGatewayJoins.iNumConnected, iNewRow, _iNumConnected);
-
- NetClient_Disconnect(pClient);
- }
-
-
-
-